<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="" id="form">
        <input type="text" id="ipt">
        <button id="btn">get数据请求</button>
    </form>
    <script>
        const obtn=document.getElementById('btn')
        const oform=document.getElementById('form')
        const oipt=document.getElementById('ipt')
        oform.onsubmit=function(e){
            // e.preventDefault()
            const xhr=new XMLHttpRequest()
            const userID=oipt.value
            xhr.open('GET',`/user/${userID}`)
            xhr.send()
            xhr.onreadystatechange=function(){
                if(xhr.readyState===4&&xhr.status>=200&&xhr.status<=299){
                    console.log(JSON.parse(xhr.responseText));
                } 
            }
            return false
        }
    </script>
</body>
</html>